home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MISC.SWG / 0096_PASCAL PASSWORD.pas < prev    next >
Pascal/Delphi Source File  |  1994-05-26  |  2KB  |  71 lines

  1. {
  2. The example that changes color and echos '*'s is nice, but does it compensate
  3. for delete/backspace/enter keypresses?
  4.  
  5. The one I posted was intended when I wrote it to be a UNIX like password
  6. input, where the cursor just sits there and doesn't react.
  7.  
  8. Does anyone want a simple password entry/encryption unit?
  9.  
  10. (I'll give it to you anyways.. ) :)
  11.  
  12. --CUT HERE-- }
  13. unit crypt;
  14. {AmoebOS v1.0 - Password/Cryyptography unit}
  15.  
  16. {Simple password entry and encryption routines}
  17. {(C)1994 Matt Sottile/RAMSoft! Freeware}
  18. {Please notify the author if you use or modify this unit in any way}
  19. {Internet mail : matts@caeser.geog.pdx.edu or matts@psg.com}
  20. {                ramsoft@industrial.com}
  21.  
  22. interface
  23.  
  24. function noecho(pmt : string) : string;
  25. function pwcrypt(op : string) : string;
  26.  
  27. implementation
  28.  
  29. uses Crt, Dos;
  30.  
  31. function noecho(pmt : string) : string;
  32. var
  33.  ch : char;
  34.  d : boolean;
  35.  temp, st : string;
  36. begin
  37.  write(pmt);
  38.  d := false;
  39.  temp := '';
  40.  st := '';
  41.  repeat
  42.   temp := st;
  43.   repeat until keypressed;
  44.   ch := readkey;
  45.   if (ch = chr(8)) then st := temp;
  46.   if (ch = chr(13)) then d := true;
  47.   if not ((ch = chr(8)) and (ch = chr(13))) then st := st+ch; 
  48.  until d = true;
  49.  noecho := temp;
  50.  writeln;
  51. end;
  52.  
  53. function pwcrypt(op : string) : string;
  54. var
  55.  ptr : integer;
  56.  ip : string;
  57. begin
  58.  ip := '';
  59.  ptr := 1;
  60.  repeat
  61.   ip := ip+chr(((ord(op[ptr])+ord(op[length(op)-ptr]) xor length(op))));
  62.   ip[ptr] := chr(ord(ip[ptr])+2);
  63.   inc(ptr);
  64.  until ptr = length(op)+1;
  65.  pwcrypt := ip;
  66. end;
  67.  
  68. begin
  69. end.
  70.  
  71.